import 'package:flutter/material.dart';

class ScrollHomePage extends StatefulWidget {
  @override
  _ScrollHomePageState createState() => _ScrollHomePageState();
}

class _ScrollHomePageState extends State<ScrollHomePage>
    with SingleTickerProviderStateMixin {
  String img =
      "https://tse3-mm.cn.bing.net/th/id/OIP.IdSm_t1f3htXl_hCwtGXLgHaEo?pid=ImgDet&rs=1";
  TabController controller;
  @override
  void initState() {
    super.initState();
    controller = new TabController(length: 3, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("scroll配置"),
        ),
        // 线性布局
        body: NestedScrollView(
          headerSliverBuilder: (BuildContext context, bool b) {
            return [
              SliverAppBar(
                // title: Text('SliverAppBar'),
                // leading: Icon(Icons.ac_unit),
                // actions: <Widget>[Icon(Icons.share)],
                // pinned 是否可滑动
                pinned: true,
                // 是否随着滑动隐藏标题
                floating: true,
                //
                expandedHeight: 160,
                flexibleSpace: FlexibleSpaceBar(
                  // title: Text('FlexibleSpaceBar'),
                  centerTitle: true,
                  background: Container(
                    color: Colors.blue[300],
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        // Text('FlexibleSpaceBar'),
                        // Text('FlexibleSpaceBar'),
                        // Text('FlexibleSpaceBar')
                        Image.network(
                          img,
                          height: 120,
                          fit: BoxFit.fill,
                        ),
                      ],
                    ),
                  ),
                ),
                bottom: TabBar(controller: controller, tabs: <Widget>[
                  new Tab(text: "标签一"),
                  new Tab(text: "标签二"),
                  new Tab(text: "标签三"),
                ]),
              ),
            ];
          },
          body: TabBarView(
            controller: controller,
            children: <Widget>[
              SingleChildScrollView(
                child: Container(
                  alignment: Alignment.bottomLeft,
                  height: 1000,
                  child: Text("container"),
                ),
              ),
              Text("这是第一个"),
              Text("这是第二个"),
            ],
          ),
        ));
  }
}
